WLST (Python) Factory pattern

Using a factory pattern for creating different subtypes like products of Oracle

class Fusion(object):
  def __init__(self):
    print "This is an Oracle Fusion Middleware product"
    def createDS(self):
    print "creating fusion datasources"

class Webcenter(object):
  def __init__(self, state):
    print "This is a Oracle Webcenter product"

class Product(object):
 products = {'fusion': Fusion, 'webcenter': Webcenter}
 def __new__(self, product):
   print "creating a new product %s" % product
   return Product.products[product]()

if __name__ == '__main__':
  product = Product('fusion')
Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: